package com.ruoyi.demo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.BasicProductMtm;
import com.ruoyi.demo.service.IBasicProductMtmService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品的机型信息Controller
 * 
 * @author metaee
 * @date 2025-05-16
 */
@RestController
@RequestMapping("/demo/mtm")
public class BasicProductMtmController extends BaseController
{
    @Autowired
    private IBasicProductMtmService basicProductMtmService;

    /**
     * 查询产品的机型信息列表
     */
    @PreAuthorize("@ss.hasPermi('demo:mtm:list')")
    @GetMapping("/list")
    public TableDataInfo list(BasicProductMtm basicProductMtm)
    {
        startPage();
        List<BasicProductMtm> list = basicProductMtmService.selectBasicProductMtmList(basicProductMtm);
        return getDataTable(list);
    }

    /**
     * 导出产品的机型信息列表
     */
    @PreAuthorize("@ss.hasPermi('demo:mtm:export')")
    @Log(title = "产品的机型信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BasicProductMtm basicProductMtm)
    {
        List<BasicProductMtm> list = basicProductMtmService.selectBasicProductMtmList(basicProductMtm);
        ExcelUtil<BasicProductMtm> util = new ExcelUtil<BasicProductMtm>(BasicProductMtm.class);
        util.exportExcel(response, list, "产品的机型信息数据");
    }

    /**
     * 获取产品的机型信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('demo:mtm:query')")
    @GetMapping(value = "/{mtm}")
    public AjaxResult getInfo(@PathVariable("mtm") String mtm)
    {
        return success(basicProductMtmService.selectBasicProductMtmByMtm(mtm));
    }

    /**
     * 新增产品的机型信息
     */
    @PreAuthorize("@ss.hasPermi('demo:mtm:add')")
    @Log(title = "产品的机型信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BasicProductMtm basicProductMtm)
    {
        return toAjax(basicProductMtmService.insertBasicProductMtm(basicProductMtm));
    }

    /**
     * 修改产品的机型信息
     */
    @PreAuthorize("@ss.hasPermi('demo:mtm:edit')")
    @Log(title = "产品的机型信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BasicProductMtm basicProductMtm)
    {
        return toAjax(basicProductMtmService.updateBasicProductMtm(basicProductMtm));
    }

    /**
     * 删除产品的机型信息
     */
    @PreAuthorize("@ss.hasPermi('demo:mtm:remove')")
    @Log(title = "产品的机型信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mtms}")
    public AjaxResult remove(@PathVariable String[] mtms)
    {
        return toAjax(basicProductMtmService.deleteBasicProductMtmByMtms(mtms));
    }
}
